﻿using System;

namespace SimbaRGVMonitor.Common.Linq
{
    public static class ExceptionExtension
    {
        public static string GetInnerExceptionMessage(this Exception ex)
        {
            var innerEx = GetInnerException(ex);
            return innerEx.Message;
        }

        public static Exception GetInnerException(this Exception ex)
        {
            var currentEx = ex;
            while(currentEx.InnerException != null)
            {
                currentEx = currentEx.InnerException;
            }
            return currentEx;
        }
    }
}
